pipeline {
    options {
        timeout(time: 1, unit: 'HOURS')
    }
    agent {
        label '192.168.188.134'
    }

    parameters  {
        string(name: 'BRANCH', defaultValue: 'master', description: '')
        string(name: 'MARKERS', defaultValue: 'all', description: '测试用例标识（多个marker用逗号分隔）')
        choice(name: 'CASE_PATH',choices: ['test_web', 'test_api','all'], description: '选择运行自动化类型')
    }

    stages {
        stage("build"){
            steps {
                script {
                    currentBuild.displayName = "#${BUILD_NUMBER} - ${params.BRANCH}"
                }
            }
        }

        stage('run test cases') {
            steps {
               sh "inv run-cases --case-path=${params.CASE_PATH} --markers=${params.MARKERS}"
            }
        }
    }
    post {
        always {
            echo '[收集测试结果]'
            script {
                publishHTML(target: [
                    reportDir: 'reports',
                    reportFiles: 'xzs.html',
                    reportName: '测试报告'
                ])
            }
        }
    }
}